{{define "title"}}首页{{end}}
{{define "seo"}}<meta name="keywords" content="{{.setting.Name}},{{.setting.SeoKeywords}},主题,资源,文章,图书,开源项目">
<meta name="description" content="{{.setting.SeoDescription}}">{{end}}
{{define "content"}}
<div class="row">
	<div class="col-md-9 col-sm-6">
		<div class="sep20"></div>
		<div class="box_white">
			<div class="inner_content" style="border-top-left-radius: 3px; border-top-right-radius: 3px;" id="tabs">
				{{range .index_navs}}
				<a href="/?tab={{.Tab}}" class="{{if eq $.tab .Tab}}tab_current{{else}}tab{{end}}">{{.Name}}</a>
				{{end}}
			</div>
			{{if .cur_nav.Children}}
			<div class="cell" style="background-color: #f9f9f9; padding: 10px 10px 10px 20px;">
				{{range .cur_nav.Children}}
				<a href="{{.Uri}}">{{.Name}}</a> &nbsp; &nbsp; 
				{{end}}
			</div>
			{{end}}

		{{with or .feeds .topics .articles .docs .subjects}}
		
			{{range $i, $feed := $.feeds}}
			<div class="cell item">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tbody><tr>
						
						<td width="48" valign="top" align="center">
						{{if .User}}
						<a href="/user/{{.User.Username}}"><img src="{{gravatar .User.Avatar .User.Email 48 $.is_https}}" class="avatar" width="48px"></a>
						{{else}}
						<a href="javascript:">
							<img class="noavatar" alt="" src="https://secure.gravatar.com/avatar/3bf6178897766ebadaa830073e87374d?s=48" data-objid="{{.Objid}}" data-objtype="{{.Objtype}}" data-author="{{.Author}}">
						</a>
						{{end}}
						</td>
						<td width="10"></td>
						
						<td width="auto" valign="middle">
							<span class="item_title"><a href="{{.Uri}}#reply{{.Cmtnum}}" class="noul" target="_blank">{{.Title}}</a></span>
							<div class="sep5"></div>
							<span class="small cc">
								{{if .Top}}
								<span style="color: #ff7700; border: 1px solid #ff7700;">置顶</span> •
								{{end}}

								{{if eq .Objtype 0}}
								<a class="node" href="/go/{{.Node.ename}}">{{.Node.name}}</a>
								{{else if eq .Objtype 1}}
								{{if .Tags}}
									{{$tags := explode .Tags ","}}
									<a class="node" href="/tag/{{index $tags 0}}">{{index $tags 0}}</a>
								{{else}}
									<a class="node" href="/articles">文章</a>
								{{end}}
								{{else if eq .Objtype 2}}
								<a class="node" href="/resources/cat/{{.Nid}}">{{.Node.name}}</a>
								{{else if eq .Objtype 3}}
								<a class="node" href="/wiki">WIKI</a>
								{{else if eq .Objtype 4}}
								<a class="node" href="/projects">开源项目</a>
								{{else if eq .Objtype 5}}
								<a class="node" href="/books">图书</a>
								{{end}}
								&nbsp;•&nbsp;

								{{if .Uid}}
								<strong><a href="/user/{{.User.Username}}" class="author">{{.User.Username}}</a></strong>
								{{else}}
								<span>{{.Author}}</span>
								{{end}}
								&nbsp;•&nbsp;
								{{if .Lastreplyuid}}
								<span title="{{.Lastreplytime}}" class="timeago"></span>&nbsp;•&nbsp;最后回复来自 <strong><a href="/user/{{.Lastreplyuser.Username}}" class="author">{{.Lastreplyuser.Username}}</a></strong>
								{{else}}
								<span title="{{.CreatedAt}}" class="timeago"></span>发布
								{{end}}
								&nbsp;•&nbsp;
								{{$likeFlag := index $.likeflags .Objid .Objtype}}
								<span class="zan-operation {{if $likeFlag}}active{{end}}" data-objid="{{.Objid}}" data-objtype="{{.Objtype}}" data-flag="{{$likeFlag}}">
									<span class="zan-wrap">
										<i class="fa fa-thumbs-up"></i>
									</span>
									{{if .Likenum}}
									<span class="zan-num">{{.Likenum}}</span>
									<span class="dot">·</span>
									{{end}}
									<span class="zan-word">{{if $likeFlag}}已赞{{else}}赞{{end}}</span>
								</span>
							</span>
						</td>
						{{if .Cmtnum}}
						<td width="70" align="right" valign="middle">
							<a href="{{.Uri}}#reply{{.Cmtnum}}" class="count_livid" title="{{.Cmtnum}}">{{.Cmtnum}}</a>
						</td>
						{{end}}
					</tr>
				</tbody></table>

			</div>
				{{if eq $i 4}}
					{{if $.pos_ad.banner}}
					
						{{if eq $.pos_ad.banner.AdType 0}}
							{{noescape $.pos_ad.banner.Code}}
						{{else}}
							<div id="ad-banner">
							</div>
						{{end}}
					
					{{end}}
				{{else if eq (mod $i 10) 4}}
					{{if $.pos_ad.feed}}

						{{if eq $.pos_ad.feed.AdType 0}}
							{{noescape $.pos_ad.feed.Code}}
						{{else}}
							<div id="ad-banner">
							</div>
						{{end}}

					{{end}}
				{{end}}
			{{end}}

			{{range $i, $topic := $.topics}}
			<div class="cell item">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tbody><tr>
						
						<td width="48" valign="top" align="center"><a href="/user/{{.user.Username}}"><img src="{{gravatar .user.Avatar .user.Email 48 $.is_https}}" class="avatar" width="48px"></a></td>
						<td width="10"></td>
						
						<td width="auto" valign="middle">
							<span class="item_title"><a href="/topics/{{.tid}}{{if .reply}}#reply{{.reply}}{{end}}" class="noul">{{.title}}</a></span>
							<div class="sep5"></div>
							<span class="small cc">
								{{if .top}}
								<span style="color: #ff7700; border: 1px solid #ff7700;">置顶</span> •
								{{end}}
								<a class="node" href="/go/{{.node.Ename}}">{{.node.Name}}</a> &nbsp;•&nbsp;
								<strong><a href="/user/{{.user.Username}}" class="author">{{.user.Username}}</a></strong> &nbsp;•&nbsp;
								{{if .lastreplyuid}}
								<span title="{{.lastreplytime}}" class="timeago"></span>&nbsp;•&nbsp;最后回复来自 <strong><a href="/user/{{.lastreplyusername}}" class="author">{{.lastreplyusername}}</a></strong>
								{{else}}
								<span title="{{.ctime}}" class="timeago"></span> 发布
								{{end}}
								&nbsp;•&nbsp;
								{{$likeFlag := index $.likeflags .tid 0}}
								<span class="zan-operation {{if $likeFlag}}active{{end}}" data-objid="{{.tid}}" data-objtype="0" data-flag="{{$likeFlag}}">
									<span class="zan-wrap">
										<i class="fa fa-thumbs-up"></i>
									</span>
									{{if .likenum}}
									<span class="zan-num">{{.likenum}}</span>
									<span class="dot">·</span>
									{{end}}
									<span class="zan-word">{{if $likeFlag}}已赞{{else}}赞{{end}}</span>
								</span>
							</span>
						</td>
						{{if .reply}}
						<td width="70" align="right" valign="middle">
							<a href="/topics/{{.tid}}#reply{{.reply}}" class="count_livid" title="{{.reply}}">{{.reply}}</a>
						</td>
						{{end}}
					</tr>
				</tbody></table>
			</div>
				{{if eq $i 4}}
					{{if $.pos_ad.other_banner}}
						{{if eq $.pos_ad.other_banner.AdType 0}}
							{{noescape $.pos_ad.other_banner.Code}}
						{{else}}
							<div id="other-banner">
							</div>
						{{end}}
					{{end}}
				{{else if eq (mod $i 10) 4}}
					{{if $.pos_ad.feed}}

						{{if eq $.pos_ad.feed.AdType 0}}
							{{noescape $.pos_ad.feed.Code}}
						{{else}}
							<div id="ad-banner">
							</div>
						{{end}}

					{{end}}
				{{end}}
			{{end}}

			{{range $i, $article := $.articles}}
			<div class="cell item">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tbody><tr>
						
						<td width="48" valign="top" align="center">
						{{if .User}}
						<a href="/user/{{.User.Username}}"><img src="{{gravatar .User.Avatar .User.Email 48 $.is_https}}" class="avatar" width="48px"></a>
						{{else}}
						<a href="javascript:">
							<img class="noavatar" alt="" src="https://secure.gravatar.com/avatar/3bf6178897766ebadaa830073e87374d?s=48" data-objid="{{.Id}}" data-objtype="1" data-author="{{.Author}}">
						</a>
						{{end}}
						</td>
						<td width="10"></td>
						
						<td width="auto" valign="middle">
							<span class="item_title"><a href="/articles/{{.Id}}" class="noul">{{.Title}}</a></span>
							<div class="sep5"></div>
							<span class="small cc">
								{{if .Top}}
								<span style="color: #ff7700; border: 1px solid #ff7700;">置顶</span> •
								{{end}}
								{{if .Tags}}
									{{$tags := explode .Tags ","}}
									<a class="node" href="/tag/{{index $tags 0}}">{{index $tags 0}}</a>
								{{else}}
									<a class="node" href="/articles">文章</a> &nbsp;•&nbsp;
								{{end}}
								{{if and .IsSelf .User}}
								<strong><a href="/user/{{.User.Username}}" class="author">{{.User.Username}}</a></strong>
								{{else}}
								<span>{{.AuthorTxt}}</span>
								{{end}}
								&nbsp;•&nbsp;
								{{if .Lastreplyuid}}
								<span title="{{.Lastreplytime}}" class="timeago"></span>&nbsp;•&nbsp;最后回复来自 <strong><a href="/user/{{.LastReplyUser.Username}}" class="author">{{.LastReplyUser.Username}}</a></strong>
								{{else}}
								<span title="{{.Ctime}}" class="timeago"></span> 发布
								{{end}}
								&nbsp;•&nbsp;
								{{$likeFlag := index $.likeflags .Id 1}}
								<span class="zan-operation {{if $likeFlag}}active{{end}}" data-objid="{{.Id}}" data-objtype="1" data-flag="{{$likeFlag}}">
									<span class="zan-wrap">
										<i class="fa fa-thumbs-up"></i>
									</span>
									{{if .Likenum}}
									<span class="zan-num">{{.Likenum}}</span>
									<span class="dot">·</span>
									{{end}}
									<span class="zan-word">{{if $likeFlag}}已赞{{else}}赞{{end}}</span>
								</span>
							</span>
						</td>
						{{if .Cmtnum}}
						<td width="70" align="right" valign="middle">
							<a href="/articles/{{.Id}}#reply{{.Cmtnum}}" class="count_livid" title="{{.Cmtnum}}">{{.Cmtnum}}</a>
						</td>
						{{end}}
					</tr>
				</tbody></table>
			</div>
				{{if eq $i 4}}
					{{if $.pos_ad.other_banner}}
						{{if eq $.pos_ad.other_banner.AdType 0}}
							{{noescape $.pos_ad.other_banner.Code}}
						{{else}}
							<div id="other-banner">
							</div>
						{{end}}
					{{end}}
				{{else if eq (mod $i 10) 4}}
					{{if $.pos_ad.feed}}

						{{if eq $.pos_ad.feed.AdType 0}}
							{{noescape $.pos_ad.feed.Code}}
						{{else}}
							<div id="ad-banner">
							</div>
						{{end}}

					{{end}}
				{{end}}
			{{end}}

			{{range $i, $doc := $.docs}}
			<div class="cell item" style="">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tbody><tr>
						<td width="48" valign="top" align="center">
						{{if .Uid}}
						{{$user := index $.users .Uid}}
						<a href="/user/{{$user.Username}}"><img src="{{gravatar $user.Avatar $user.Email 48 $.is_https}}" class="avatar" width="48px"></a>
						{{else}}
						<a href="javascript:">
							<img class="noavatar" alt="" src="https://secure.gravatar.com/avatar/3bf6178897766ebadaa830073e87374d?s=48" data-objid="{{.Objid}}" data-objtype="{{.Objtype}}" data-author="{{.Author}}">
						</a>
						{{end}}
						</td>
						<td width="10"></td>
						
						<td width="auto" valign="middle">
							<span class="item_title">
								<a class="title noul" href="/{{if eq .Objtype 0}}topics{{else if eq .Objtype 1}}articles{{else if eq .Objtype 2}}resources{{else if eq .Objtype 4}}p{{else}}wiki{{end}}/{{.Objid}}{{if .Cmtnum}}#reply{{.Cmtnum}}{{end}}" title="{{.Title}}">{{.Title}}</a>
							</span>
							<div class="sep5"></div>
							<span class="small c9">
							{{if .Nid}}
								{{$node := index $.nodes .Nid}}
								<a class="node" href="/go/{{$node.Ename}}">{{$node.Name}}</a>
							{{else}}
								{{if .Tags}}
									{{$tags := explode .Tags ","}}
									<a class="node" href="/tag/{{index $tags 0}}">{{index $tags 0}}</a>
								{{else}}
									{{if eq .Objtype 1}}
									<a class="node" href="/articles">文章</a>
									{{else if eq .Objtype 2}}
									<a class="node" href="/resources">分享发现</a>
									{{else if eq .Objtype 3}}
									<a class="node" href="/wiki">WIKI</a>
									{{else if eq .Objtype 4}}
									<a class="node" href="/projects">开源项目</a>
									{{end}}
								{{end}}
							{{end}}
								&nbsp;•&nbsp; 
							{{if .Uid}}
								{{$user := index $.users .Uid}}
								 <strong><a href="/user/{{$user.Username}}" class="author">{{$user.Username}}</a></strong>
							{{else}}
								<span>{{.Author}}</span>
							{{end}}
								&nbsp;•&nbsp; 
							{{if .Lastreplyuid}}
								{{$user := index $.users .Lastreplyuid}}
								<span title="{{.Lastreplytime}}" class="timeago"></span>&nbsp;•&nbsp; 最后回复来自 <strong><a href="/user/{{$user.Username}}" class="author">{{$user.Username}}</a></strong>
							{{else}}
								<span title="{{.PubTime}}" class="timeago"></span> 发布
							{{end}}
								&nbsp;•&nbsp;
								{{$likeFlag := index $.likeflags .Objid .Objtype}}
								<span class="zan-operation {{if $likeFlag}}active{{end}}" data-objid="{{.Objid}}" data-objtype="{{.Objtype}}" data-flag="{{$likeFlag}}">
									<span class="zan-wrap">
										<i class="fa fa-thumbs-up"></i>
									</span>
									{{if .Likenum}}
										<span class="zan-num">{{.Likenum}}</span>
										<span class="dot">·</span>
									{{end}}
									<span class="zan-word">{{if $likeFlag}}已赞{{else}}赞{{end}}</span>
								</span>
							</span>
						</td>
						{{if .Cmtnum}}
						<td width="70" align="right" valign="middle">
							<a href="/{{if eq .Objtype 0}}topics{{else if eq .Objtype 1}}articles{{else if eq .Objtype 2}}resources{{else if eq .Objtype 4}}p{{else}}wiki{{end}}/{{.Objid}}#reply{{.Cmtnum}}" class="count_livid" title="{{.Cmtnum}}">{{.Cmtnum}}</a>
						</td>
						{{end}}

					</tr>
				</tbody></table>
			</div>
				{{if eq $i 4}}
					{{if $.pos_ad.other_banner}}
						{{if eq $.pos_ad.other_banner.AdType 0}}
							{{noescape $.pos_ad.other_banner.Code}}
						{{else}}
							<div id="other-banner">
							</div>
						{{end}}
					{{end}}
				{{else if eq (mod $i 10) 4}}
					{{if $.pos_ad.feed}}

						{{if eq $.pos_ad.feed.AdType 0}}
							{{noescape $.pos_ad.feed.Code}}
						{{else}}
							<div id="ad-banner">
							</div>
						{{end}}

					{{end}}
				{{end}}
			{{end}}

			{{range $i, $subject := $.subjects}}
			<div class="cell item">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tbody><tr>
						
						<td width="48" valign="top" align="center">
							<a href="/subject/{{.Id}}">
							{{if .Cover}}
								<img src="{{imageUrl .Cover $.is_https}}?imageView2/2/w/48" class="avatar" width="48px">
							{{else}}
								<img src="{{gravatar .User.Avatar .User.Email 48 $.is_https}}" class="avatar" width="48px">
							{{end}}
							</a>
						</td>
						<td width="10"></td>
						
						<td width="auto" valign="middle">
							<span class="item_title"><a href="/subject/{{.Id}}" class="noul">{{.Name}}</a></span>
							<div class="sep5"></div>
							<span class="small cc">
								<a class="node" href="/subject/{{.Id}}">专栏</a> &nbsp;•&nbsp;
								<strong><a href="/user/{{.User.Username}}" class="author">{{.User.Username}}</a></strong>
								&nbsp;•&nbsp;
							{{if .ArticleNum}}
								<span title="{{.UpdatedAt}}" class="timeago"></span> 有新文章
							{{else}}
								创建于<span title="{{.CreatedAt}}" class="timeago"></span>
							{{end}}
							</span>
						</td>
						{{if .ArticleNum}}
						<td width="70" align="right" valign="middle">
							<a href="/subject/{{.Id}}" class="count_livid" title="{{.ArticleNum}}">{{.ArticleNum}}</a>
						</td>
						{{end}}
					</tr>
				</tbody></table>
			</div>
				{{if eq $i 4}}
					{{if $.pos_ad.other_banner}}
						{{if eq $.pos_ad.other_banner.AdType 0}}
							{{noescape $.pos_ad.other_banner.Code}}
						{{else}}
							<div id="other-banner">
							</div>
						{{end}}
					{{end}}
				{{else if eq (mod $i 10) 4}}
					{{if $.pos_ad.feed}}

						{{if eq $.pos_ad.feed.AdType 0}}
							{{noescape $.pos_ad.feed.Code}}
						{{else}}
							<div id="ad-banner">
							</div>
						{{end}}

					{{end}}
				{{end}}
			{{end}}
			
			{{if $.page}}
			<div class="box_white">
				<div class="inner_content">
					<nav class="text-center"><ul class="pagination pagination-sm" style="margin: 1px 0;">{{$.page}}</ul></nav>
				</div>
			</div>
			{{end}}

		{{else}}

			<div class="cell item">
				<div class="pull-right"><a href="/topics/new">我来发布</a> <i class="fa fa-caret-right c9"></i></div>
				<span class="text-center" style="display: inherit">暂无主题</span>
			</div>
		{{end}}
		
		</div>
	
		<div class="sep20"></div>
		<div class="box_white">
			<div class="cell">
				<div class="pull-right"><a href="/nodes">浏览全部节点</a></div>
				<span class="cc">节点导航</span>
			</div>
			{{range .all_nodes}}
			<div class="cell">
				<table cellpadding="0" cellspacing="0" border="0"><tbody>
					<tr>
					{{range $parent, $children := .}}
						<td align="right" width="65"><span class="cc">{{$parent}}</span></td>
						<td style="line-height: 200%; padding-left: 10px; word-break: keep-all;">
						{{range $children}}
							<a href="/go/{{.ename}}?fr=index_node" style="font-size: 14px;" class="noul" title="{{.name}}">{{.name}}</a>&nbsp; &nbsp;
						{{end}}
						</td>
					{{end}}
					</tr>
				</tbody></table>
			</div>
			{{end}}
			
		</div>

	</div>
	<div class="col-md-3 col-sm-6">
		<div class="sep20"></div>

		{{include "common/my_info.html" .}}

		{{if .pos_ad.right1}}
		<div class="box_white sidebar" id="ad-right1">
			{{if eq .pos_ad.right1.AdType 0}}
				{{noescape .pos_ad.right1.Code}}
			{{end}}
		</div>
		{{end}}

		{{include "sidebar/reading.html" .}}

		{{include "sidebar/comment.html" .}}

		{{include "sidebar/new_user.html" .}}
		
		{{include "sidebar/active_user.html" .}}

		{{if .pos_ad.right2}}
		<div class="box_white sidebar" id="ad-right2">
			{{if eq .pos_ad.right2.AdType 0}}
				{{noescape .pos_ad.right2.Code}}
			{{end}}
		</div>
		{{end}}

		{{include "sidebar/stat.html" .}}

		{{include "sidebar/friend_link.html" .}}

		{{include "sidebar/concern.html" .}}
		
	</div>
</div>


{{end}}
{{define "js"}}
<script src="https://cdn.bootcss.com/identicon.js/2.3.1/identicon.min.js"></script>
<script type="text/javascript">
// 需要加载的侧边栏
SG.SIDE_BARS = [
	"/comments/recent",
	"/users/active",
	"/users/newest",
	"/websites/stat",
	"/readings/recent",
	"/friend/links",
];

$(function() {
	$('.noavatar').each(function() {
		var objid = $(this).data('objid'),
			objtype = $(this).data('objtype'),
			author = $(this).data('author');
		// var hash = md5(objid+"-"+objtype);
		var hash = md5(author+"");
		var data = new Identicon(hash, {format: 'svg', size: 48}).toString();
		var imgData = 'data:image/svg+xml;base64,' + data;
		$(this).attr('src', imgData);
	});
});

</script>
{{if .pos_ad.banner}}
	{{if eq .pos_ad.banner.AdType 1}}
		{{noescape .pos_ad.banner.Code}}
	{{end}}
{{end}}

{{end}}
